<script setup>
import {reactive, ref} from "vue";
import {PUT} from "../../../api/index.js";
import {typeOptions} from "../../../utils/listData.js";

const dialogFormVisible = ref(false)
const emit = defineEmits(['ok'])
const form = reactive({
  id: '',
  upPrice: '',
  downPrice: '',
  costPrice: '',
  num: '',
})

const open = (row) => {
  form.id = row.id
  form.upPrice = row.upPrice
  form.downPrice = row.downPrice
  form.num = row.num
  form.costPrice = row.costPrice
  dialogFormVisible.value = true
}

const saveHandle = () => {
  PUT('/market/user', form).then(res => {
    dialogFormVisible.value = false
    emit('ok')
  })
}

defineExpose({
  open
})
</script>

<template>
  <el-dialog v-model="dialogFormVisible" title="编辑" width="500">
    <el-form :model="form" label-width="80">
      <el-form-item label="上涨突破">
        <el-input v-model="form.upPrice" autocomplete="off" />
      </el-form-item>
      <el-form-item label="下跌突破">
        <el-input v-model="form.downPrice" autocomplete="off" />
      </el-form-item>
      <el-form-item label="持仓成本">
        <el-input v-model="form.costPrice" autocomplete="off" />
      </el-form-item>
      <el-form-item label="持仓数量">
        <el-input v-model="form.num" autocomplete="off" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="saveHandle">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<style scoped lang="scss">

</style>